<?php /* Smarty version Smarty3-SVN$Rev: 3286 $, created on 2011-12-15 14:10:15
         compiled from "D:\www\beimuaihui/views/admin\system/resource_role.tpl" */ ?>
<?php /*%%SmartyHeaderCode:122214ee98f47c579b1-94982584%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'f070887a22698bdcb8e8a7c20bf7faeb7c3e49b5' => 
    array (
      0 => 'D:\\www\\beimuaihui/views/admin\\system/resource_role.tpl',
      1 => 1320130973,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '122214ee98f47c579b1-94982584',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
)); /*/%%SmartyHeaderCode%%*/?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html>
<head>
<?php $_template = new Smarty_Internal_Template('header.tpl', $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
$_template->assign('JS',@BAOGG_JS);$_template->assign('CSS',@BAOGG_CSS); echo $_template->getRenderedTemplate(); $_template->rendered_content = null;?><?php unset($_template);?>        
        
        <script type="text/javascript"> 
           
          	Ext.onReady(function(){
			Ext.get("check_all_resource") && Ext.get("check_all_resource").on("click",function(){
				Ext.select("input[type=checkbox][name^=resource_row_id]").each(function(el,c,idx){
					el.dom.checked=Ext.get("check_all_resource").dom.checked;
					Ext.select("input[name='resource_op_code"+el.dom.name.replace("resource_row_id","")+"[]']").each(function(subel,subc,subidx){
						subel.dom.checked=el.dom.checked;
					});
				})
			});
			Ext.select("input[type=checkbox][name^=resource_row_id]").each(function(el,c,idx){
				
				el.on("click",function(e,t,o){
					//console.info("input[name='resource_op_code"+t.name.replace("resource_row_id","")+"[]']");
					Ext.select("input[name='resource_op_code"+t.name.replace("resource_row_id","")+"[]']").each(function(subel,subc,subidx){
						subel.dom.checked=t.checked;
					});
				});				
			});
          		Ext.get("submit") && Ext.get("submit").on("click",function(){
	          		Ext.Ajax.request({
	          		    form: 'form1',
	          		  	success: function(form, action) {		
	          		  		//console.info(action);		
	          		  	  var result=Ext.decode(form.responseText);
	          		  	  if(result.success){
		          		  		 top.top.Ext.example.msg('<?php echo $_smarty_tpl->getVariable('LANG')->value['save'];?>
', '<?php echo $_smarty_tpl->getVariable('LANG')->value['save_ok'];?>
');
			          		  	 parent.Ext.getCmp("resource_role_win").close();
	          		  	  }else{
		          		  		 Ext.MessageBox.show({
			          		           title: '<?php echo $_smarty_tpl->getVariable('LANG')->value['save_fail'];?>
',
			          		           msg: result.msg,
			          		           buttons: Ext.MessageBox.OK,
			          		           icon:  Ext.MessageBox.ERROR
			          		       });
	          		  	  }					   				
	     			    },
	     			   failure: function(form, action) {
	    					switch (action.failureType) {
	    					    case Ext.form.Action.CLIENT_INVALID:
	    						top.Ext.example.msg('<?php echo $_smarty_tpl->getVariable('LANG')->value['save_fail'];?>
', "Form fields may not be submitted with invalid values");
	    						break;
	    					    case Ext.form.Action.CONNECT_FAILURE:
	    						top.Ext.example.msg('<?php echo $_smarty_tpl->getVariable('LANG')->value['save_fail'];?>
', "Ajax communication failed");
	    						break;
	    					    case Ext.form.Action.SERVER_INVALID:
	    					       top.Ext.example.msg('<?php echo $_smarty_tpl->getVariable('LANG')->value['save_fail'];?>
', action.result.msg);
	    					       break;
	    					    default:
	    					      top.Ext.example.msg('<?php echo $_smarty_tpl->getVariable('LANG')->value['save_fail'];?>
', action.result.msg);
	    					      break;
	    				       }
	    				   }
	          		});

          		});
          		 
          	});
          	
          </script>	
</head>
<body>       
<form method="post" id="form1" name="form1" action="<?php echo @BAOGG_BASE_URL;?>
system/resource/role/">

	<div id="toolbar">
		<?php if (!$_smarty_tpl->getVariable('gridShow')->value){?>
			<input type="submit" value="<?php echo $_smarty_tpl->getVariable('LANG')->value['save'];?>
"  />		
		<?php }else{ ?>
			<input type="button" value="<?php echo $_smarty_tpl->getVariable('LANG')->value['save'];?>
" id="submit" name="submit" />
		<?php }?>
	</div>

	<hr />
	<div id="form">
		<?php if (!$_smarty_tpl->getVariable('gridShow')->value){?>
		<div id="div_role">
			<select name="role_id" id="role_id">
				<?php  $_smarty_tpl->tpl_vars['role'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('roles')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['role']->key => $_smarty_tpl->tpl_vars['role']->value){
?>
					<?php if ($_smarty_tpl->getVariable('role_id')->value==$_smarty_tpl->tpl_vars['role']->value['role_id']){?>
						<option value="<?php echo $_smarty_tpl->tpl_vars['role']->value['role_id'];?>
" selected><?php echo $_smarty_tpl->tpl_vars['role']->value['role_name'];?>
</option>
					<?php }else{ ?>
						<option value="<?php echo $_smarty_tpl->tpl_vars['role']->value['role_id'];?>
"><?php echo $_smarty_tpl->tpl_vars['role']->value['role_name'];?>
</option>
					<?php }?>
				<?php }} ?>
			</select>
		  
			<select name="resource_id" id="resource_id">
				<?php  $_smarty_tpl->tpl_vars['resource'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('resources')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['resource']->key => $_smarty_tpl->tpl_vars['resource']->value){
?>
					<?php if ($_smarty_tpl->getVariable('resource_id')->value==$_smarty_tpl->tpl_vars['resource']->value['resource_id']){?>
						<option value="<?php echo $_smarty_tpl->tpl_vars['resource']->value['resource_id'];?>
" selected><?php echo $_smarty_tpl->tpl_vars['resource']->value['resource_name'];?>
</option>
					<?php }else{ ?>
						<option value="<?php echo $_smarty_tpl->tpl_vars['resource']->value['resource_id'];?>
"><?php echo $_smarty_tpl->tpl_vars['resource']->value['resource_name'];?>
</option>
					<?php }?>
				<?php }} ?>
			</select>
		</div>
	
		<?php }else{ ?>
		
		<table class="grid">
			<thead>
				<tr>
				<th><input type="checkbox" id="check_all_resource" /></th>
				
				<th>Resouce</th>
				<th>Op</th>
				</tr>
			</thead>
			<tbody>
			<?php  $_smarty_tpl->tpl_vars['resource'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('resources')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['resource']->key => $_smarty_tpl->tpl_vars['resource']->value){
?>
			<tr>
				<td>
				<?php if ($_smarty_tpl->tpl_vars['resource']->value['is_resourced']){?>				
				<input type="checkbox" name="resource_row_id[<?php echo $_smarty_tpl->tpl_vars['resource']->value['key_col'];?>
]" 
				<?php if (isset($_smarty_tpl->getVariable('permission',null,true,false)->value[$_smarty_tpl->tpl_vars['resource']->value['key_col']])){?>
					checked 
				<?php }?>				
				 />
				 <?php }?>
				 </td>
				<td> <?php echo $_smarty_tpl->tpl_vars['resource']->value['show_col'];?>
</td>
				<td>
				<?php if ($_smarty_tpl->tpl_vars['resource']->value['is_oped']){?>
				<?php  $_smarty_tpl->tpl_vars['operation'] = new Smarty_Variable;
 $_from = $_smarty_tpl->getVariable('operations')->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
if ($_smarty_tpl->_count($_from) > 0){
    foreach ($_from as $_smarty_tpl->tpl_vars['operation']->key => $_smarty_tpl->tpl_vars['operation']->value){
?>
					<input type="checkbox" name="resource_op_code[<?php echo $_smarty_tpl->tpl_vars['resource']->value['key_col'];?>
][]" value="<?php echo $_smarty_tpl->tpl_vars['operation']->value['resource_op_code'];?>
"
					<?php if (isset($_smarty_tpl->getVariable('permission',null,true,false)->value[$_smarty_tpl->tpl_vars['resource']->value['key_col']])&&strpos($_smarty_tpl->getVariable('permission')->value[$_smarty_tpl->tpl_vars['resource']->value['key_col']]['resource_op_code'],$_smarty_tpl->tpl_vars['operation']->value['resource_op_code'])!==false){?>
						checked 
					<?php }?>
					/><lable><?php echo $_smarty_tpl->tpl_vars['operation']->value['resource_op_name'];?>
</lable> &nbsp; 
				<?php }} ?>
				<?php }?>
				</td>	
			</tr>
			<?php }} ?>
			</tbody>
		</table>
		<input type="hidden" name="role_id" value="<?php echo $_smarty_tpl->getVariable('role_id')->value;?>
" />
		<input type="hidden" name="resource_id" value="<?php echo $_smarty_tpl->getVariable('resource_id')->value;?>
" />
		<?php }?>
	</div>

</form>
</body>
</html>